export const datalistMixins = {
    // 触底
    onReachBottom() {
    	if (this.pageobj.page_size > 10) {
    		this.pageobj.page_no = Math.ceil(this.pageobj.page_size / 10)
    		this.pageobj.page_size = 10
    	}
    	if (this.pageobj.page_total > this.pageobj.page_no) {
    		this.pageobj.page_no += 1
    		this.getDatasList()
    	} else {
    		if (this.pageobj.list.length) {
				// this.$toast({
				// 	title: '到底了'
				// })
    		}
    	}
    },
	
	methods: {
		// 列表重置
		ResetRefresh() {
			this.pageobj.page_size = 10
			this.pageobj.page_no = 1
			this.pageobj.page_total = 0
			this.pageobj.list = []
			this.pageobj.initial = true
			this.getDatasList()
		},
		// 原地页面刷新 数据变动
		InsituRefresh() {
			this.pageobj.page_size = this.pageobj.page_size * this.pageobj.page_no
			this.pageobj.page_no = 1
			this.page_total = 0
			this.pageobj.initial = true
			this.getDatasList()
		},
		// 筛选返回结果
		screenresult(resArr){
			for(let val of resArr) {
				let {key,value} = val
				this.pageobj[key] = value
			}
			this.ResetRefresh()
		},
		
		// 处理列表数据
		def_handleDatas(resobj) {
			let {
				count,
				lists,
			} = resobj
			let {
				page_size,
				initial
			} = this.pageobj
			let newlist = this.$zhTran(lists)
			for (let item of lists) {
				if (!initial) {
					this.pageobj.list.push(item)
				}
			}
			if (initial) { // 初次加载
				this.pageobj.page_total = Math.ceil(count / page_size)
				this.pageobj.list = lists
				this.pageobj.initial = false
			}
			
			uni.stopPullDownRefresh()
		},
	},
	 
}

